﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameInput;
using Terraria.Graphics;
using Terraria.UI;

namespace Terraria.ModLoader
{
	// Token: 0x020001D9 RID: 473
	internal static class ModHooks
	{
		// Token: 0x06001371 RID: 4977 RVA: 0x00410900 File Offset: 0x0040EB00
		internal static void UpdateMusic(ref int music, ref MusicPriority priority)
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				int num = -1;
				MusicPriority musicPriority = MusicPriority.BiomeLow;
				mod.UpdateMusic(ref num, ref musicPriority);
				if (num >= 0 && musicPriority >= priority)
				{
					music = num;
					priority = musicPriority;
				}
			}
		}

		// Token: 0x06001372 RID: 4978 RVA: 0x00410968 File Offset: 0x0040EB68
		internal static void HotKeyPressed()
		{
			foreach (KeyValuePair<string, ModHotKey> keyValuePair in ModLoader.modHotKeys)
			{
				if (PlayerInput.Triggers.Current.KeyStatus[keyValuePair.Value.displayName])
				{
					keyValuePair.Value.mod.HotKeyPressed(keyValuePair.Value.name);
				}
			}
		}

		// Token: 0x06001373 RID: 4979 RVA: 0x004109EC File Offset: 0x0040EBEC
		internal static void ModifyTransformMatrix(ref SpriteViewMatrix Transform)
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.ModifyTransformMatrix(ref Transform);
			}
		}

		// Token: 0x06001374 RID: 4980 RVA: 0x00410A40 File Offset: 0x0040EC40
		internal static void ModifySunLight(ref Color tileColor, ref Color backgroundColor)
		{
			if (Main.gameMenu)
			{
				return;
			}
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.ModifySunLightColor(ref tileColor, ref backgroundColor);
			}
		}

		// Token: 0x06001375 RID: 4981 RVA: 0x00410A9C File Offset: 0x0040EC9C
		internal static void ModifyLightingBrightness(ref float negLight, ref float negLight2)
		{
			float num = 1f;
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.ModifyLightingBrightness(ref num);
			}
			if (Lighting.NotRetro)
			{
				negLight *= num;
				negLight2 *= num;
			}
			else
			{
				negLight -= (num - 1f) / 2.30769229f;
				negLight2 -= (num - 1f) / 0.75f;
			}
			negLight = Math.Max(negLight, 0.001f);
			negLight2 = Math.Max(negLight2, 0.001f);
		}

		// Token: 0x06001376 RID: 4982 RVA: 0x00410B4C File Offset: 0x0040ED4C
		internal static void PostDrawFullscreenMap(ref string mouseText)
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.PostDrawFullscreenMap(ref mouseText);
			}
		}

		// Token: 0x06001377 RID: 4983 RVA: 0x00410BA0 File Offset: 0x0040EDA0
		internal static void UpdateUI(GameTime gameTime)
		{
			if (Main.gameMenu)
			{
				return;
			}
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.UpdateUI(gameTime);
			}
		}

		// Token: 0x06001378 RID: 4984 RVA: 0x00410BFC File Offset: 0x0040EDFC
		internal static void ModifyInterfaceLayers(List<GameInterfaceLayer> layers)
		{
			foreach (GameInterfaceLayer gameInterfaceLayer in layers)
			{
				gameInterfaceLayer.Active = true;
			}
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.ModifyInterfaceLayers(layers);
			}
		}

		// Token: 0x06001379 RID: 4985 RVA: 0x00410C8C File Offset: 0x0040EE8C
		internal static void PostDrawInterface(SpriteBatch spriteBatch)
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.PostDrawInterface(spriteBatch);
			}
		}

		// Token: 0x0600137A RID: 4986 RVA: 0x00410CE0 File Offset: 0x0040EEE0
		internal static void PostUpdateInput()
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.PostUpdateInput();
			}
		}

		// Token: 0x0600137B RID: 4987 RVA: 0x00410D30 File Offset: 0x0040EF30
		internal static void PreSaveAndQuit()
		{
			foreach (Mod mod in ModLoader.mods.Values)
			{
				mod.PreSaveAndQuit();
			}
		}
	}
}
